﻿using DocumentFormat.OpenXml.Wordprocessing;
using Magicodes.ExporterAndImporter.Core.Extension;
using Microsoft.Extensions.Logging;
using NP.BPMReportPlatform.AuthorizationUserManager;
using NP.BPMReportPlatform.AuthorizationUserManager.Dtos;
using NP.BPMReportPlatform.Course.Dtos;
using NP.BPMReportPlatform.DBHelper;
using NP.BPMReportPlatform.Entities.BPM_Business;
using NP.BPMReportPlatform.Entities.BPM_Process;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.Course
{
    public class CourseBaseAppService : BPMReportPlatformAppService, ICourseBaseAppService
    {
        private readonly SqlSugarClient _db;
        public CourseBaseAppService(ISqlSugarAppService sqlSugarAppService)
        {
            _db = sqlSugarAppService.GetBusinessInstance();
        }

        /// <summary>
        /// 获取课程基础对象集合
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task<List<CourseBase>> GetCourseBase(CourseBaseInput input)
        {
            return await _db.Queryable<CourseBase>()
                .Where(x => x.Status == 1)
                .WhereIF(!string.IsNullOrWhiteSpace(input.CourseCode), x => x.CourseCode.Contains(input.CourseCode))
                .WhereIF(!string.IsNullOrWhiteSpace(input.CourseName), x => x.CourseName.Contains(input.CourseName))
                .ToListAsync();
        }
    }
}
